<!--
 * @Description: 角色
 * @Author: zhailei
 * @Date: 2021-01-18 15:17:27
 * @LastEditTime: 2021-05-21 14:29:41
 * 
 * @FilePath: \-cloud-topvui\src\components\TopVUI\custom\TSelectRole.vue
-->
<template>
  <t-select-biz-component
    ref="TSelectRole"
    :value="value"
    name="角色"
    displayKey="roleName"
    :returnKeys="returnKeys"
    :paramList="paramsList"
    :listUrl="url.list"
    :columns="columns"
    queryParamText="角色编码"
    v-on="$listeners"
    v-bind="$attrs"
    :showBtn="showBtn"
    :url="url"
    :treeDataField="
      typeof treeDataField == 'object' ? loadRootField : treeDataField
    "
    :loadRootField="loadRootField"
    :userDataField="userDataField"
    :treeDataObj="treeDataObj"
  />
</template>

<script>
import TSelectBizComponent from "./TSelectBizComponent";

export default {
  name: "TSelectRole",
  components: {
    TSelectBizComponent,
  },
  // props: [
  // 	'value'
  // ],
  props: {
    paramsList: {
      type: Array,
      default: () => [],
    },
    showBtn: {
      type: Boolean,
      default: true,
    },
    // 企业微信  钉钉同时使用本组件需要提取更改项
    url: {
      type: Object,
      default: () => {
        return {
          masterList: "/mdata/nail/getORGUserAllList",
          fathersUrl: "/mdata/nail/getORG?orgId=1",
          expandUrl: "/mdata/nail/getORG",
        };
      },
    },
    loadRootField: {
      type: Function,
      default: (data) => {
        data.map((item, index) => {
          item.id = item.parent_id + "-" + item.dept_id;
          item.value = item.dept_id;
          item.title = item.name;
          item.children = [];
        });
        return data;
      },
    },
    treeDataField: {
      type: Function | Object,
      default: () => new Object(),
    },
    userDataField: {
      type: Function,
      default: (data) => data,
    },
    treeDataObj: {
      type: Array,
      default: () => [{ keys: "orgId", value: "dept_id" }],
    },
  },
  data() {
    return {
      value: "",
      returnKeys: ["uuid", "userNameId"],
      // url: {
      // 	list: '/mdata/user/getPageSet',
      // },
      columns: [
        {
          title: "姓名",
          dataIndex: "userName",
          align: "left",
          width: 160,
        },
        {
          title: "工号",
          dataIndex: "userNameId",
          align: "left",
        },
      ],
    };
  },
  methods: {
    show(e) {
      this.$refs.TSelectRole.show(e);
    },
  },
};
</script>

<style lang="less" scoped></style>
